﻿<%
String host_address = (String)session.getValue("mysql_host_address");
String host_port = (String)session.getValue("mysql_host_port");
String host_username = (String)session.getValue("mysql_host_username");
String host_password = (String)session.getValue("mysql_host_password");
if (host_address == null || host_port == null || host_username == null || host_password == null)
{
	Cookie cookies[] = request.getCookies();
	boolean found_cookie = false;
	for (int i = 0; cookies != null && i < cookies.length; i++)
	{
		Cookie current_cookie = cookies[i];
		String remember_setup_string = "";
		if (current_cookie.getName().equals("mysql_remember_setup"))
		{
			remember_setup_string = current_cookie.getValue();
			String [] remember_setups = remember_setup_string.split(",");
			session.putValue("mysql_host_address", remember_setups[0]);
			session.putValue("mysql_host_port", remember_setups[1]);
			session.putValue("mysql_host_username", remember_setups[2]);
			session.putValue("mysql_host_password", remember_setups[3]);
			host_address = (String)session.getValue("mysql_host_address");
			host_port = (String)session.getValue("mysql_host_port");
			host_username = (String)session.getValue("mysql_host_username");
			host_password = (String)session.getValue("mysql_host_password");
			database.initDatabase(host_address, host_port, host_username, host_password);
			found_cookie = true;
			break;
		}
	}
	if (found_cookie == false)
	{
	%>
	<script type="text/javascript">
	<!--
		window.alert("会话超时，请重新登录服务器！");
		window.location.href = "connection.jsp?type=new";
	//-->
	</script>
	<%
	out.close();
	}
}
else
	database.initDatabase(host_address, host_port, host_username, host_password);
%>